package com.Java.train.business.service.Impl;

import cn.hutool.core.bean.BeanUtil;
import com.Java.train.business.entity.DTO.SeatSellDTO;
import com.Java.train.business.entity.DailyTrainSeat;
import com.Java.train.business.req.SeatSellReq;
import com.Java.train.business.service.SeatSellService;
import com.Java.train.business.service.daily.DailyTrainSeatService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jakarta.annotation.Resource;
import lombok.Setter;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class SeatSellServiceImpl implements SeatSellService {
    @Resource
    DailyTrainSeatService dailyTrainSeatService;
    /**
      * @Description: 查询所有座位
      * @param 车次编号和日期
      * @return
      */
    @Override
    public List<SeatSellDTO> query(SeatSellReq seatSellReq) {
        LambdaQueryWrapper<DailyTrainSeat> wrapper = new LambdaQueryWrapper<>();
        List<DailyTrainSeat> list = dailyTrainSeatService.list(wrapper.eq(DailyTrainSeat::getTrainCode, seatSellReq.getTrainCode())
                .eq(DailyTrainSeat::getDate, seatSellReq.getDate()));
        List<SeatSellDTO> seatSellList = BeanUtil.copyToList(list, SeatSellDTO.class);
        return seatSellList;
    }
}
